package com.moniteach.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.moniteach.R;
import com.moniteach.bo.Group;

public class GroupAdapter extends ArrayAdapter<Group> {
	private List<Group> objects;
	private LayoutInflater inflater;

	public GroupAdapter(Context context, int textViewResourceId,
			List<Group> objects) {
		super(context, textViewResourceId, objects);
		this.objects = objects;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		if (convertView == null)
			vi = inflater.inflate(R.layout.group_item, null);
		TextView t = (TextView) vi.findViewById(R.id.tvNameGroup);
		t.setText(objects.get(position).getName());
		TextView tt = (TextView) vi.findViewById(R.id.tvDescGroup);
		tt.setText(objects.get(position).getDescription());

		return vi;
	}

}
